package com.kmproject.haifu.mvp.ui.activity;

import android.app.AlertDialog;
import android.content.Intent;
import android.graphics.Paint;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.widget.NestedScrollView;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.jess.arms.base.BaseActivity;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.http.imageloader.glide.ImageConfigImpl;
import com.jess.arms.utils.ArmsUtils;
import com.jess.arms.utils.DataHelper;
import com.kmproject.haifu.R;
import com.kmproject.haifu.app.AppConstant;
import com.kmproject.haifu.app.hfinterface.HouseReasonRemovalCallBack;
import com.kmproject.haifu.app.utils.AppUtil;
import com.kmproject.haifu.app.utils.ExtensionUtilKt;
import com.kmproject.haifu.app.utils.TimeUtils;
import com.kmproject.haifu.app.utils.ViewExtensionKt;
import com.kmproject.haifu.di.component.DaggerSecondHandInfoShowComponent;
import com.kmproject.haifu.mvp.contract.SecondHandInfoShowContract;
import com.kmproject.haifu.mvp.model.api.Api;
import com.kmproject.haifu.mvp.model.entity.beans.HousePayWayBean;
import com.kmproject.haifu.mvp.model.entity.beans.SecondHandInfoBean;
import com.kmproject.haifu.mvp.model.entity.beans.UserBean;
import com.kmproject.haifu.mvp.presenter.SecondHandInfoShowPresenter;
import com.kmproject.haifu.mvp.ui.adapter.SecondHandImgAdapter;
import com.kmproject.haifu.mvp.ui.adapter.SecondHandPublicshBqForInfoAdapter;
import com.kmproject.haifu.mvp.ui.widget.CircleImageView;
import com.kmproject.haifu.mvp.ui.widget.RoundCornerImageView;
import com.library.flowlayout.FlowLayoutManager;
import com.library.flowlayout.SpaceItemDecoration;
import com.like.LikeButton;
import com.like.OnLikeListener;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

import static com.jess.arms.utils.Preconditions.checkNotNull;


/**
 * ================================================
 * Description:
 * <p>
 * Created by MVPArmsTemplate on 09/02/2019 09:56
 * <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
 * <a href="https://github.com/JessYanCoding">Follow me</a>
 * <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
 * <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
 * <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
 * ================================================
 */
public class SecondHandInfoShowActivity extends BaseActivity<SecondHandInfoShowPresenter> implements SecondHandInfoShowContract.View {

    @BindView(R.id.second_hand_show_item_qx)
    TextView secondHandShowItemQx;
    @BindView(R.id.second_hand_show_item_descript)
    TextView secondHandShowItemDescript;
    @BindView(R.id.secondhand_showInfo_content_sjjg)
    TextView secondhandShowInfoContentSjjg;
    @BindView(R.id.secondhand_showInfo_content_ysjg)
    TextView secondhandShowInfoContentYsjg;
    @BindView(R.id.secondhand_showInfo_content_RecyclerView)
    RecyclerView secondhandShowInfoContentRecyclerView;
    @BindView(R.id.secondhand_showInfo_content_address)
    TextView secondhandShowInfoContentAddress;
    @BindView(R.id.secondhand_showInfo_content_address_img)
    ImageView secondhandShowInfoContentAddressImg;
    @BindView(R.id.secondhand_showInfo_content_descpript)
    TextView secondhandShowInfoContentDescpript;
    @BindView(R.id.secondhand_showInfo_content_descpript_lay)
    LinearLayout secondhandShowInfoContentDescpriptLay;
    @BindView(R.id.secondhand_showInfo_content_RecyclerView_img)
    RecyclerView secondhandShowInfoContentRecyclerViewImg;
    @BindView(R.id.secondhand_showInfo_content_ll)
    TextView secondhandShowInfoContentLl;
    @BindView(R.id.secondhand_showInfo_content_fbsj)
    TextView secondhandShowInfoContentFbsj;
    @BindView(R.id.activity_house_rent_show_wxh_txt)
    TextView activityHouseRentShowWxhTxt;
    @BindView(R.id.activity_house_rent_show_wxh_lay)
    LinearLayout activityHouseRentShowWxhLay;
    @BindView(R.id.activity_house_rent_show_lxdh_txt)
    TextView activityHouseRentShowLxdhTxt;
    @BindView(R.id.activity_house_rent_show_fdxxCenter_lay)
    LinearLayout activityHouseRentShowFdxxCenterLay;
    @BindView(R.id.scrollview)
    NestedScrollView scrollview;
    @BindView(R.id.house_info_show_fyyxj)
    TextView houseInfoShowFyyxj;
    @BindView(R.id.house_info_show_fywzs)
    TextView houseInfoShowFywzs;
    @BindView(R.id.activity_house_rent_show_btn12)
    LikeButton activityHouseRentShowBtn12;
    @BindView(R.id.activity_house_rent_show_sc_lay)
    LinearLayout activityHouseRentShowScLay;
    @BindView(R.id.activity_house_rent_show_fwfbz_img)
    ImageView activityHouseRentShowFwfbzImg;
    @BindView(R.id.activity_house_rent_show_fwfbz_txt)
    TextView activityHouseRentShowFwfbzTxt;
    @BindView(R.id.activity_house_rent_show_fwfbz_lay)
    LinearLayout activityHouseRentShowFwfbzLay;
    @BindView(R.id.activity_house_rent_show_tv13)
    TextView activityHouseRentShowTv13;
    @BindView(R.id.activity_house_rent_show_tv14)
    TextView activityHouseRentShowTv14;
    @BindView(R.id.activity_house_rent_common_lay)
    LinearLayout activityHouseRentCommonLay;
    @BindView(R.id.activity_house_rent_show_time)
    TextView activityHouseRentShowTime;
    @BindView(R.id.activity_house_rent_show_edit)
    TextView activityHouseRentShowEdit;
    @BindView(R.id.activity_house_rent_show_obt)
    TextView activityHouseRentShowObt;
    @BindView(R.id.activity_house_rent_userCenter_lay)
    LinearLayout activityHouseRentUserCenterLay;
    @BindView(R.id.activity_house_rent_show_info_back)
    ImageView activityHouseRentShowInfoBack;
    @BindView(R.id.activity_house_rent_show_info_share)
    ImageView activityHouseRentShowInfoShare;
    @BindView(R.id.activity_house_rent_show_msg)
    ImageView activityHouseRentShowMsg;
    @BindView(R.id.activity_house_rent_show_infoTitle_lay)
    LinearLayout activityHouseRentShowInfoTitleLay;
    @BindView(R.id.rl_root_layout)
    RelativeLayout rlRootLayout;
    List<HousePayWayBean> housePayWayBeans;//下架提示语
    @BindView(R.id.activity_house_rent_show_header_img)
    CircleImageView activityHouseRentShowHeaderImg;
    @BindView(R.id.activity_house_rent_show_tv7)
    TextView activityHouseRentShowTv7;
    @BindView(R.id.activity_house_rent_show_img)
    ImageView activityHouseRentShowImg;
    @BindView(R.id.activity_house_rent_show_tv9)
    TextView activityHouseRentShowTv9;
    @BindView(R.id.activity_house_rent_show_tv10)
    TextView activityHouseRentShowTv10;
    @BindView(R.id.activity_house_rent_show_fdxx_lay)
    LinearLayout activityHouseRentShowFdxxLay;
    @BindView(R.id.activity_sp_show_header_img)
    RoundCornerImageView activitySpShowHeaderImg;
    @BindView(R.id.activity_sp_name_txt)
    TextView activitySpNameTxt;
    @BindView(R.id.activity_sp_dl_img)
    TextView activitySpDlImg;
    @BindView(R.id.activity_sp_hydj_img)
    ImageView activitySpHydjImg;
    @BindView(R.id.activity_sp_zxfy_img)
    TextView activitySpZxfyImg;
    @BindView(R.id.activity_house_rent_show_sp_lay)
    LinearLayout activityHouseRentShowSpLay;
    SecondHandInfoBean msecondHandInfoBean;
    private View dialogView;
    private AlertDialog dialog;
    @Override
    public void setupActivityComponent(@NonNull AppComponent appComponent) {
        DaggerSecondHandInfoShowComponent //如找不到该类,请编译一下项目
                .builder()
                .appComponent(appComponent)
                .view(this)
                .build()
                .inject(this);
    }

    @Override
    public int initView(@Nullable Bundle savedInstanceState) {
        return R.layout.activity_second_hand_info_show; //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0
    }

    @Override
    public void initData(@Nullable Bundle savedInstanceState) {
        if (!getIntent().hasExtra("secondHandId")) {
            showMessage("参数异常");
            killMyself();
            return;
        }
        initGlide();
        mPresenter.secondHandLookOne(getIntent().getStringExtra("secondHandId"));
        if (getIntent().hasExtra("type")) {
            //从个人中心进来的 //userCenter
            mPresenter.dictList(Api.SECOND_LOWER_SHELF_REASON, "");//下架提示语
        }

    }

    /**
     * 不同地方进来控制显示
     *
     * @param secondHandInfoBean
     */
    public void uiContalShow(SecondHandInfoBean secondHandInfoBean) {
        activityHouseRentShowFwfbzLay.setVisibility(View.INVISIBLE);
        if (secondHandInfoBean.getPublishWay() == 1) {
            //店铺发布
            activityHouseRentShowFdxxLay.setVisibility(View.GONE);
            activityHouseRentShowSpLay.setVisibility(View.VISIBLE);
            mglideImage.loadImage(this, ImageConfigImpl.builder().url(secondHandInfoBean.getStoreInfo().getStoreLogo())
                    .imageView(activitySpShowHeaderImg)
                    .build());
            activitySpNameTxt.setText(secondHandInfoBean.getStoreInfo().getStoreName());
            activitySpDlImg.setText(secondHandInfoBean.getStoreInfo().getStoreRankName());
            mglideImage.loadImage(this, ImageConfigImpl.builder().url(secondHandInfoBean.getUserInfo().getLevelHeadImage())
                    .imageView(activitySpHydjImg)
                    .build());
            activitySpZxfyImg.setText("在线二手物品" + secondHandInfoBean.getStoreInfo().getOnlineSecondHandCount() + "个");
            activityHouseRentShowSpLay.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent intent=new Intent(SecondHandInfoShowActivity.this, MyStoreSecondHandActivity.class);
                    intent.putExtra("userStoreId",msecondHandInfoBean.getUserStoreId());
                  if(AppUtil.userIsLogin(SecondHandInfoShowActivity.this))
                  {
                      UserBean userBean = DataHelper.getDeviceData(SecondHandInfoShowActivity.this, AppConstant.USER_INFO);//获取用户信息
                      if (userBean.getUserId().equals(msecondHandInfoBean.getUserInfo().getUserId()))
                      {
                          intent.putExtra("userId",msecondHandInfoBean.getUserInfo().getUserId());
                      }
                  }
                    startActivity(intent);


                }
            });

        } else {
            //用户发布
            activityHouseRentShowFdxxLay.setVisibility(View.VISIBLE);
            activityHouseRentShowSpLay.setVisibility(View.GONE);
            if (secondHandInfoBean.getUserInfo().getAvatar()!=null&&!TextUtils.isEmpty(secondHandInfoBean.getUserInfo().getAvatar()))
            {
                mglideImage.loadImage(this, ImageConfigImpl.builder().url(secondHandInfoBean.getUserInfo().getAvatar())
                        .imageView(activityHouseRentShowHeaderImg)
                        .build());
            }

            activityHouseRentShowTv7.setText(secondHandInfoBean.getUserInfo().getNickName());
            mglideImage.loadImage(this, ImageConfigImpl.builder().url(secondHandInfoBean.getUserInfo().getLevelHeadImage())
                    .imageView(activityHouseRentShowImg)
                    .build());
            activityHouseRentShowTv9.setText("来海服" + secondHandInfoBean.getUserInfo().getRegisterLongTime() + "," + secondHandInfoBean.getUserInfo().getUserSex() + "," + secondHandInfoBean.getUserInfo().getOnlineStatus());
            activityHouseRentShowFdxxLay.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                  //跳转到用户中心
                    Intent intent1 = new Intent(SecondHandInfoShowActivity.this, PersonalHomePageActivity.class);
                    intent1.putExtra("userId ", msecondHandInfoBean.getUserInfo().getUserId());
                    AppConstant.PHConstant.phUserId = msecondHandInfoBean.getUserInfo().getUserId();
                    ArmsUtils.startActivity(intent1);

                }
            });
        }

        if (getIntent().hasExtra("type")) {
            //从个人中心进来的
            houseInfoShowFyyxj.setVisibility(View.VISIBLE);
            houseInfoShowFywzs.setVisibility(View.VISIBLE);
            activityHouseRentShowFdxxCenterLay.setVisibility(View.VISIBLE);
            activityHouseRentUserCenterLay.setVisibility(View.VISIBLE);
            activityHouseRentCommonLay.setVisibility(View.GONE);
            if (secondHandInfoBean.getWechat() != null && !TextUtils.isEmpty(secondHandInfoBean.getWechat())) {
                activityHouseRentShowWxhTxt.setText(secondHandInfoBean.getWechat());
            } else {
                activityHouseRentShowWxhLay.setVisibility(View.GONE);
            }
            if (secondHandInfoBean.getMobile() != null && !TextUtils.isEmpty(secondHandInfoBean.getMobile())) {
                activityHouseRentShowLxdhTxt.setText("+" + (secondHandInfoBean.getMobile().substring(0, 2)) + " " + (secondHandInfoBean.getMobile().substring(2, secondHandInfoBean.getMobile().length())));
            }

            if (secondHandInfoBean.getIsShow()==0)
            {
                //过期
                houseInfoShowFyyxj.setVisibility(View.GONE);
                houseInfoShowFywzs.setVisibility(View.GONE);
                activityHouseRentShowEdit.setText("升级会员");
                activityHouseRentShowObt.setText("下架");
                activityHouseRentShowTime.setText("会员已过期,升级会员方可显示");
                activityHouseRentShowTime.setTextColor(ArmsUtils.getColor(this,R.color.color_FF3A3A));
                activityHouseRentShowEdit.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Intent intent = new Intent(SecondHandInfoShowActivity.this, MemberCenterMainActivity.class);
                        intent.putExtra("type", "house_updateMember");//从房屋跳转到升级会员界面
                        startActivityForResult(intent,1001);
                    }
                });

                activityHouseRentShowObt.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        //下架
                        mPresenter.houseReasonRemoval(SecondHandInfoShowActivity.this, activityHouseRentShowObt, housePayWayBeans, new HouseReasonRemovalCallBack() {
                            @Override
                            public void callBack(HousePayWayBean housePayWayBean) {
                                if (housePayWayBean != null) {
                                    mPresenter.lowerShelfSecondHand( housePayWayBean.getDictId(),msecondHandInfoBean.getSecondHandId());
                                }
                            }
                        });
                    }
                });

                return;
            }
            if (secondHandInfoBean.getIsAvailable()==0)
            {
                //已下架
//                secondHandInfoBean.getCreateTime()
                activityHouseRentUserCenterLay.setVisibility(View.GONE);
          if (Integer.parseInt(secondHandInfoBean.getCreateTime().substring(0,4))< Integer.parseInt(TimeUtils.getYear()))
          {
              //可以删除
              houseInfoShowFyyxj.setVisibility(View.VISIBLE);
              activityHouseRentShowTime.setVisibility(View.INVISIBLE);
              activityHouseRentShowEdit.setVisibility(View.GONE);
              activityHouseRentShowObt.setText("删除");
              activityHouseRentShowObt.setOnClickListener(new View.OnClickListener() {
                  @Override
                  public void onClick(View v) {
                      //下架超过一年可以删除\
                      mPresenter.remoredSencond(msecondHandInfoBean.getSecondHandId());
                  }
              });
          }else {
              //不可以删除
              houseInfoShowFywzs.setVisibility(View.VISIBLE);
          }
                return;
            }

        //审核通过,的判断可不可以编辑
            houseInfoShowFyyxj.setVisibility(View.GONE);
            houseInfoShowFywzs.setVisibility(View.GONE);
         if (secondHandInfoBean.getStopEditTime()!=null&&!TextUtils.isEmpty(secondHandInfoBean.getStopEditTime())&&secondHandInfoBean.getStopEditTime().length()>1)
         {
             //可以编辑
             activityHouseRentShowTime.setText(secondHandInfoBean.getStopEditTime()+"后禁止编辑");
             activityHouseRentShowTime.setTextColor(ArmsUtils.getColor(this,R.color.color_999999));
             activityHouseRentShowEdit.setText("编辑");
             activityHouseRentShowObt.setText("下架");
             activityHouseRentShowEdit.setOnClickListener(new View.OnClickListener() {
                 @Override
                 public void onClick(View v) {
                     Intent intent= new Intent(SecondHandInfoShowActivity.this,SecondHandPublicshActivity.class);
                     intent.putExtra("secondHandId",msecondHandInfoBean.getSecondHandId());
                     startActivityForResult(intent,1001);
                 }
             });
             activityHouseRentShowObt.setOnClickListener(new View.OnClickListener() {
                 @Override
                 public void onClick(View v) {
                     //下架
                     mPresenter.houseReasonRemoval(SecondHandInfoShowActivity.this, activityHouseRentShowObt, housePayWayBeans, new HouseReasonRemovalCallBack() {
                         @Override
                         public void callBack(HousePayWayBean housePayWayBean) {
                             if (housePayWayBean != null) {
                                 mPresenter.lowerShelfSecondHand(msecondHandInfoBean.getSecondHandId(), housePayWayBean.getDictId());
                             }
                         }
                     });
                 }
             });
         }else {
             //不可以编辑
             activityHouseRentShowTime.setVisibility(View.INVISIBLE);
             activityHouseRentShowEdit.setVisibility(View.INVISIBLE);

             activityHouseRentShowObt.setText("下架");
             activityHouseRentShowObt.setOnClickListener(new View.OnClickListener() {
                 @Override
                 public void onClick(View v) {
                     //下架
                     mPresenter.houseReasonRemoval(SecondHandInfoShowActivity.this, activityHouseRentShowObt, housePayWayBeans, new HouseReasonRemovalCallBack() {
                         @Override
                         public void callBack(HousePayWayBean housePayWayBean) {
                             if (housePayWayBean != null) {
                                 mPresenter.lowerShelfSecondHand(msecondHandInfoBean.getSecondHandId(), housePayWayBean.getDictId());
                             }
                         }
                     });
                 }
             });
         }




        } else {
            //普通用户进来的
            houseInfoShowFyyxj.setVisibility(View.GONE);
            houseInfoShowFywzs.setVisibility(View.GONE);
            activityHouseRentShowFdxxCenterLay.setVisibility(View.GONE);
            activityHouseRentUserCenterLay.setVisibility(View.GONE);
            activityHouseRentCommonLay.setVisibility(View.VISIBLE);
        }
        String temLabName = "";
        if (secondHandInfoBean.getLabels() != null && !secondHandInfoBean.getLabels().isEmpty()) {
            secondhandShowInfoContentRecyclerView.setVisibility(View.VISIBLE);
            SecondHandPublicshBqForInfoAdapter secondHandPublicshBqAdapter = new SecondHandPublicshBqForInfoAdapter(secondHandInfoBean.getLabels());
            secondhandShowInfoContentRecyclerView.setLayoutManager(new GridLayoutManager(this,4));
            secondhandShowInfoContentRecyclerView.setAdapter(secondHandPublicshBqAdapter);

            for (SecondHandInfoBean.LabelsBean labelsBean : secondHandInfoBean.getLabels()) {
                if (labelsBean.getName().contains("全新")) {
                    temLabName = labelsBean.getName();
                    break;
                }
            }
        } else {
            secondhandShowInfoContentRecyclerView.setVisibility(View.GONE);
        }
        if (!TextUtils.isEmpty(temLabName)) {
            secondHandShowItemQx.setVisibility(View.VISIBLE);
            secondHandShowItemDescript.setText("\u3000\u3000" + (secondHandInfoBean.getTitle() == null ? "" : secondHandInfoBean.getTitle()));
        } else {
            secondHandShowItemQx.setVisibility(View.GONE);
            if (secondHandInfoBean.getTitle() == null || TextUtils.isEmpty(secondHandInfoBean.getTitle())) {
                secondHandShowItemDescript.setVisibility(View.GONE);
            } else {
                secondHandShowItemDescript.setVisibility(View.VISIBLE);
            }
            secondHandShowItemDescript.setText(secondHandInfoBean.getTitle() == null ? "" : secondHandInfoBean.getTitle());
        }

    }

    @Override
    public void showLoading() {
        loadingDialog.show();
    }

    @Override
    public void hideLoading() {
        loadingDialog.dismiss();
    }

    @Override
    public void showMessage(@NonNull String message) {
        checkNotNull(message);
        ArmsUtils.snackbarText(message);
    }

    @Override
    public void launchActivity(@NonNull Intent intent) {
        checkNotNull(intent);
        ArmsUtils.startActivity(intent);
    }

    @Override
    public void killMyself() {
        finish();
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }

    @Override
    public void secondHandLookOneSuccess(SecondHandInfoBean secondHandInfoBean) {
        msecondHandInfoBean=secondHandInfoBean;
        uiContalShow(secondHandInfoBean);
        secondhandShowInfoContentSjjg.setText(secondHandInfoBean.getSalePrice() + "P");
        if (secondHandInfoBean.getBuyPrice() == null || TextUtils.isEmpty(secondHandInfoBean.getBuyPrice()) || "0".equals(secondHandInfoBean.getBuyPrice())) {
            secondhandShowInfoContentYsjg.setVisibility(View.GONE);
        } else {
            secondhandShowInfoContentYsjg.setVisibility(View.VISIBLE);
            secondhandShowInfoContentYsjg.setText(secondHandInfoBean.getBuyPrice() + "P");
            secondhandShowInfoContentYsjg.setPaintFlags(Paint.STRIKE_THRU_TEXT_FLAG);
        }
        if (secondHandInfoBean.getAreaInfo() != null && !secondHandInfoBean.getAreaInfo().isEmpty()) {
            secondhandShowInfoContentAddress.setText(" "+secondHandInfoBean.getAreaInfo().get(secondHandInfoBean.getAreaInfo().size() - 1).getName() + " | " + secondHandInfoBean.getDistance());
        }
        if (secondHandInfoBean.getDetail() == null || TextUtils.isEmpty(secondHandInfoBean.getDetail())) {
            secondhandShowInfoContentDescpriptLay.setVisibility(View.GONE);
        } else {
            secondhandShowInfoContentDescpript.setText(secondHandInfoBean.getDetail());
        }
        secondhandShowInfoContentRecyclerViewImg.setLayoutManager(new LinearLayoutManager(this));
        SecondHandImgAdapter secondHandImgAdapter = new SecondHandImgAdapter(secondHandInfoBean.getImages());
//        secondhandShowInfoContentRecyclerViewImg.addItemDecoration(new SpaceItemDecoration(AppUtil.dp2px(10)));
        secondhandShowInfoContentRecyclerViewImg.setAdapter(secondHandImgAdapter);
        secondHandImgAdapter.openLoadAnimation(BaseQuickAdapter.SCALEIN);
        secondhandShowInfoContentLl.setText(secondHandInfoBean.getViewCount() + "次浏览\u3000" + secondHandInfoBean.getCollectionCount() + "人想要");
        if (secondHandInfoBean.getCollected() == 0) {
            activityHouseRentShowBtn12.setLiked(false);
        } else {
            activityHouseRentShowBtn12.setLiked(true);
        }
        activityHouseRentShowBtn12.setOnLikeListener(new OnLikeListener() {
            @Override
            public void liked(LikeButton likeButton) {
                if (!AppUtil.userIsLogin(SecondHandInfoShowActivity.this))
                {
                    ArmsUtils.startActivity(UserLoginActivity.class);
                    showMessage("请先登录");
                    return;
                }
                mPresenter.collestSecondHand(getIntent().getStringExtra("secondHandId"));
            }

            @Override
            public void unLiked(LikeButton likeButton) {
                if (!AppUtil.userIsLogin(SecondHandInfoShowActivity.this))
                {
                    ArmsUtils.startActivity(UserLoginActivity.class);
                    showMessage("请先登录");
                    return;
                }
                mPresenter.cancelCollestSecondHand(getIntent().getStringExtra("secondHandId"));
            }
        });
    }

    @Override
    public void dictListSuccess(List<HousePayWayBean> housePayWayBeans) {

    }

    @Override
    public void lowerShelfSecondHandSuccess() {
        showMessage("下架成功");
    }

    @Override
    public void collestSecondHandSuccess() {
        activityHouseRentShowBtn12.post(new Runnable() {
            @Override
            public void run() {
                showMessage("收藏成功");
            }
        });

        activityHouseRentShowBtn12.setLiked(true);
    }

    @Override
    public void cancelCollestSecondHandSuccess() {
        activityHouseRentShowBtn12.post(new Runnable() {
            @Override
            public void run() {
                showMessage("取消成功");
            }
        });

        activityHouseRentShowBtn12.setLiked(false);
    }

    @Override
    public void remoredSencondSuccess() {
        showMessage("删除成功");
        killMyself();
    }

    @OnClick({R.id.secondhand_showInfo_content_address_img,R.id.activity_house_rent_show_info_share,R.id.activity_house_rent_show_info_back,R.id.activity_house_rent_show_tv13, R.id.activity_house_rent_show_tv14})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.secondhand_showInfo_content_address_img:
//                地图
                //跳转到地图界面
                Intent intent = new Intent(this, MapOneShowActivity.class);
                intent.putExtra("lat", msecondHandInfoBean.getLat());
                intent.putExtra("lgt", msecondHandInfoBean.getLgt());
                ArmsUtils.startActivity(intent);
                break;
            case R.id.activity_house_rent_show_info_share:
                AppUtil.sharePopuWindow(this,activityHouseRentShowInfoShare,msecondHandInfoBean.getTitle(),"",msecondHandInfoBean.getDetail(),(msecondHandInfoBean.getImages()==null||
                        msecondHandInfoBean.getImages().isEmpty())?"":msecondHandInfoBean.getImages().get(0).getImageUrl(),Api.SHARE_SENONDHNAD_URL+msecondHandInfoBean.getSecondHandId());
                break;
            case R.id.activity_house_rent_show_info_back:
                killMyself();
                break;
            case R.id.activity_house_rent_show_tv13:
                //加微信
                if (msecondHandInfoBean != null) {
                    if (dialogView == null) {
                        dialogView = ViewExtensionKt.inflate(rlRootLayout, R.layout.v_rent_seeking_show_we_chat, false);
                        ((TextView) dialogView.findViewById(R.id.tv_name)).setText(String.format(getString(R.string.rent_seeking_detail_fm_3), msecondHandInfoBean.getUserInfo().getNickName()));
                        ((TextView) dialogView.findViewById(R.id.tv_we_chat_number)).setText(msecondHandInfoBean.getWechat());
                        dialogView.findViewById(R.id.tv_we_copy_we_chat).setOnClickListener(v -> {
                            ExtensionUtilKt.copyText(SecondHandInfoShowActivity.this, msecondHandInfoBean.getWechat());
                            showMessage("复制成功");
                            dialog.dismiss();
                        });
                    }
                    if (dialog == null) {
                        dialog = new AlertDialog.Builder(this, R.style.dialog1).create();
                    }
                    addWeChat();
                }
                break;
            case R.id.activity_house_rent_show_tv14:
                if (msecondHandInfoBean == null) {
                    showMessage("未获取到用户信息");
                    return;
                }
                String temPhone = "";
                if ("86".equals(msecondHandInfoBean.getMobile().substring(0, 2))) {
                    temPhone = msecondHandInfoBean.getMobile().substring(2, msecondHandInfoBean.getMobile().length());
                } else {
                    temPhone = msecondHandInfoBean.getMobile();
                }
                Intent dialIntent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + temPhone));//跳转到拨号界面，同时传递电话号码
                startActivity(dialIntent);
                break;

        }
    }
    private void addWeChat() {
        ViewExtensionKt.showCenterDialog(dialogView, dialog, true);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode==RESULT_OK&&data!=null&&requestCode==1001&&msecondHandInfoBean!=null)
        {
            //刷新数据
            mPresenter.collestSecondHand(msecondHandInfoBean.getSecondHandId());
        }
    }


}
